<template>
    <div class="child2">
        <h3>孙组件</h3>
        <h4>银子：{{ money }}万</h4>
        <h4>车：一辆{{ car.brand }}车价值{{ car.prcie }}万</h4>

        <button @click="updateMoney(1)">花爷爷的钱</button>
    </div>
</template>

<script setup lang="ts" name="GrandChild">
import { inject } from 'vue'
let { money, updateMoney } = inject('moneyContext', { money: 0,updateMoney:(x:number)=> { }})
let car = inject('car', { brand: "未知", prcie: 0 })

</script>

<style  scoped>
.child2 {
    background-color: rgb(56, 76, 226);
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 10px black;
}
</style>